---
id: audio
title: Audio Node
sidebar_label: Audio
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

![Audio Node Screenshot](./assets/audio-node.png)

## Overview

The Audio Node is used to define an audio sample for use with other nodes. It can also convert a binary type into an audio type.

The Audio Node can either take an input that represents the audio data or use an audio file specified in the node's settings. The audio data should be in a format that can be converted to a Uint8Array.

<Tabs
  defaultValue="inputs"
  values={[
    {label: 'Inputs', value: 'inputs'},
    {label: 'Outputs', value: 'outputs'},
    {label: 'Editor Settings', value: 'settings'},
  ]
}>

<TabItem value="inputs">

## Inputs

| Title | Data Type | Description                             | Default Value | Notes                                                                                                             |
| ----- | --------- | --------------------------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------- |
| Data  | `string`  | The string representing the audio data. | N/A           | This input is only available if the "Use Data Input" setting is enabled. The input will be coerced into a string. |

</TabItem>

<TabItem value="outputs">

## Outputs

| Title      | Data Type | Description                                                                                             | Notes |
| ---------- | --------- | ------------------------------------------------------------------------------------------------------- | ----- |
| Audio Data | `audio`   | The audio data converted into a format that can be used by other nodes that accept audio data as input. |       |

</TabItem>

<TabItem value="settings">

## Editor Settings

| Setting        | Description                                                                                                                                                                             | Default Value | Use Input Toggle | Input Data Type |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | ---------------- | --------------- |
| Audio File     | The audio file to be used as the audio data. This file should be in a format that can be converted to a Uint8Array.                                                                     | N/A           | Yes              | `file`          |
| Use Data Input | If enabled, the node will use the data from the "Data" input port as the audio data. If disabled, the node will use the data from the audio file specified in the "Audio File" setting. | False         | No               | N/A             |

</TabItem>

</Tabs>

## Example 1: Using an Audio Node with a File

1. Add an Audio Node to your graph.
2. In the node's settings, click "Pick File" and select an audio file from your local file system.
3. Play the audio back using the player on the Audio node. You may also connect the Audio node to other nodes that accept Audio data, such as the [AssemblyAI Plugin](../user-guide/plugins/built-in/assemblyai.md)

## Error Handling

The Audio Node will throw an error if:

- The "Use Data Input" setting is enabled but no data is provided to the "Data" input port.
- The "Use Data Input" setting is disabled but no audio file is specified in the "Audio File" setting.
- The provided audio data (either from the "Data" input or the specified audio file) cannot be converted to a Uint8Array.

## FAQ

**Q: What audio file formats are supported by the Audio Node?**

A: The Audio Node does not process the audio data itself, so it does not have any specific audio file format requirements. However, the audio data should be in a format that can be converted to a Uint8Array. The specific audio file formats that can be used will depend on what other nodes you are connecting the Audio Node to.

**Q: Can I use the Audio Node to play audio?**

A: The Audio Node shows a playback bar on the Rivet UI, but otherwise, it cannot be used to play back audio during the graph's execution.

## See Also

- [Image Node](./image.mdx)
- [Text Node](./text.mdx)
- [Number Node](./number.mdx)
- [Bool Node](./bool.mdx)
- [External Call Node](./external-call.mdx)
